<template>
	<view class="" style="padding-bottom: 100rpx;">
		<view class="flex flex-col justify-start items-center">
			<image src="@/static/image/canting.jpg" mode="widthFix" class="bg"></image>
			<view class="box flex flex-col justify-start">
				<view class="name c_0 f_32">{{desc.name}}</view>
				<view class="name c_3 f_28 mt_20">营业时间：{{desc.yingye}}</view>
			<!-- 	<view class="taglist flex flex-row items-center justify-start">
					<view class="tag">可预约</view>
					<view class="tag">可唐诗</view>
				</view> -->
				<view class="flex flex-row mt_40" @tap="call(desc.mobile)">
					<image src="@/static/image/telicon@2x.png" mode="widthFix" style="width: 40rpx;margin-right: 10rpx;"></image>
					<text>{{desc.mobile}}</text>
				</view>
			</view>
		</view>
		<view class="tablist flex flex-row justify-center items-center" style="margin-top: -80rpx;">
			<view class="tab f_32 "  :class="active==index?'active':''" v-for="(item,index) in FileList" :key="index" @click="tab1(index)">
				{{item.name}}
			</view>
		</view>
		<view class="flex flex-col justify-between box-item "  v-if="active==0">
			<view class="flex flex-row justify-between"  >
				<view class="namea" :class="active1==index?'active1':''" v-for="(item,index) in list" :key="index" @click="tab(item.name,index)">
					{{item.name}}
				</view>
			</view>
			
			<view class="cai flex flex-row flex-wrap mt_40 justify-between items-center" >
				<view class="flex flex-col justify-center items-center mt_20" v-for="(item,index) in imglist" :key="index">
					<image :src="$util.img(item.image)" mode="" class="cai_img" @click="cimg($util.img(item.image))"></image>
					<text class="f_28 c_0 mt_20">{{item.name}} ￥{{item.price}}</text>
				</view>
				
			</view>
			
		</view>
		
		<view class="flex flex-col justify-between box-item "  v-else>
			<view class="flex flex-row justify-between"  >
				<view class="namea" :class="active2==index?'active2':''" v-for="(item,index) in dateri" :key="index" @click="tabdate(item,index)">
					{{item}}
				</view>
			</view>
			
			<view class="cai flex flex-row flex-wrap mt_40 justify-between items-center" >
				<view class="flex flex-col justify-center items-center mt_20 w100" v-for="(item,index) in datedesc" :key="index">
					<image :src="$util.img(item.image)" mode="widthFix" style="width: 100%;" @click="cimg($util.img(item.image))"></image>
					<text class="f_28 c_0 mt_20">{{item.name}} ￥{{item.price}}</text>
				</view>
				
			</view>
			
		</view>
		<!-- <view class="btn" @click="goother">在线点餐</view> -->
	</view>
</template>
<script>
	import {
		getFormatDate,
		getFormatDatenow
	} from "@/common/js/util.js";

	import http from 'common/js/http.js';

	export default {
		 
		mixins: [http],
		data() {

			const [year, month, date] = getFormatDate().split("-");
			const [year1, month2, date2, hour2, minute2, second2] = getFormatDatenow().split("-");
			return {
				datedesc:{},
				imglist:[],
				active:0,
				active1:0,
				active2:0,
				desc:{},
				type:'',
				dateri:['周日','周六','周五','周四','周三','周二','周一'],
				FileList:[
					{
						name:'食谱菜品'
					},
					{
						name:'爱心套餐'
					},
				],
				list:[
					{
						name:'盖饭'
					},
					{
						name:'热菜'
					},
					{
						name:'凉菜'
					},
					{
						name:'主食'
					},
					
					
				
				]
				
			}
		},
		onLoad(data) {
			this.getdetail()
		
		},
		onShow() {
		this.getlist()
		this.getimglist(this.list[0].name)
		this.tabdate('周日',0)
		},
		methods: {
			goother(){
				wx.navigateToMiniProgram({
				    appId: 'wx2290598ce591e3d5',
				  
				    //develop开发版；trial体验版；release正式版
				    envVersion: 'release', 
				    success(res) {
				      // 打开成功
				      console.log("跳转小程序成功！",res);
				    } 
				})
			},
			tabdate(date,index){
				this.active2=index
				this.sendRequest({
					url:'Canteen/pack',
					data:{
						canteen_id:3,
						type:date
					},success:res=>{
						this.datedesc=res.data
						
					}
				})
				
			},
			tab1(index){
				this.active=index
			},
			cimg(ig){
				uni.previewImage({
					urls:[ig],
					
				})
			},
			tab(name,index){
				this.active1=index
				this.getimglist(name)
			},
			call(number){
				uni.makePhoneCall({
					phoneNumber:number
				})
			},
			getdetail(){
				this.sendRequest({
					url:'Canteen/index',
					data:{
						town_id:1
					},success:res=>{
						this.desc=res.data
						
					}
				})
			},
			getimglist(name){
				this.sendRequest({
					url:'Canteen/menu',
					data:{
						canteen_id:3,
						type:name
					},success:res=>{
						this.imglist=res.data
						
					}
				})
			},
			getlist(){
				this.sendRequest({
					url: 'cun/partymemberlist',
					data: {
						town_id: 1,
						type:this.type
					},
					success: res => {
						console.log(res)
						if (res.code > 0) {
				res.data.map(item=>{
					item.show = false
				})
							this.list = res.data
							this.list[0].show=true
						}
					}
				})
			},
			
		show(item,index){
			let a = item.show
			this.list.map(e=>{
				e.show=false
			})
			this.list[index].show=!a
		},
			getbanner() {
				this.sendRequest({
					url: 'cun/block',
					data: {
						town_id: 1
					},
					success: res => {
						console.log(res)
						if (res.code > 0) {
							
							this.list = res.data
						}
					}
				})
			},
			
		
		
		}
	}
</script>


<style lang="scss">
	.btn{
		position: fixed;
		bottom: 30rpx;
		background-color: #ff5500;
		color: #fff;
		font-size: 28rpx;
		width: 80%;
		left: 10%;
		height: 80rpx;
		line-height:80rpx;
		border-radius:20rpx;
		text-align: center;
	}
	.box-item{
		width: 95%;
		padding: 30rpx 40rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin: 20rpx auto;
		.cai_img{
			width: 300rpx;
			height: 300rpx;
			border: 1rpx solid #ebebeb;
		}
	}
	.namea{
		line-height: 2;
		color:#666
	}
	.active1{
		color: #000;
		font-size: 32rpx;
		border-bottom:4rpx solid #55aaff;
	}
	.tab{
		width: 30%;
		display: flex;
		justify-content: center;
		align-items: center;
		line-height: 2;
		color: #000;
		font-weight: bold;
		
		border-bottom: 4rpx solid rgba(0,0,0,0);
	}
	.active{
		color: #55aaff;
		border-bottom:4rpx solid #55aaff;
	}
	.active2{
		color: #55aaff;
		border-bottom:4rpx solid #55aaff;
	}
	.bg{
		width: 100%;
		
	}
	.box{
		width: 95%;
		position: absolute;
		padding: 30rpx;
		top:320rpx;
		background-color: #fff;
		border-radius: 20rpx;
		box-shadow: 0 0 0rpx 5rpx  rgba(154, 148, 124, 0.3);
		.taglist{
			margin-top: 20rpx;
			.tag{
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: #f4f4f4;
				padding:0 10rpx;
				height: 50rpx;
				border-radius: 10rpx;
				margin-right: 20rpx;
					font-size: 26rpx;
			}
		}
	}
</style>